import  matplotlib.pyplot as plt
import  pandas as pd

# x = [1,2,3,4,5]
# y1 = [6,9,5,8,4]
# y2 = [3,2,5,4,2]
# y3 = [8,9,7,4,3]
# y4 = [7,4,6,7,12]
#
# plt.stackplot(x,y1,y2,y3,y4,colors =['g','c','r','b'])
# plt.show()

# df = pd.read_excel(r'./data/books.xlsx')
# # 中文乱码
# # plt.rcParams['font.sans-serif'] = ['SimHei']
# plt.rcParams['font.sans-serif'] = ['Heiti TC']
#
# x = df['年份']
# y = df['销售额']
#
# plt.title('2013-2018线上销售情况')
# plt.stackplot(x,y)
# plt.show()


df = pd.read_excel(r'./data/books.xlsx',sheet_name='Sheet2')
# 中文乱码
# plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['font.sans-serif'] = ['Heiti TC']
x = df['年份']
y1 = df['京东']
y2 = df['天猫']
y3 = df['自营']
plt.title('2013-2019年线上图书销售情况')
plt.stackplot(x, y1,y2,y3,colors=['#6d904f','#fc4f30','#008fd5'])
#图例
plt.legend(['京东','天猫','自营'],loc='upper left')
plt.show()
